<?php
class collegeController extends RPHP_Controller
{

    public function index()
    {

        $m    = $this->model;
        $user = $m->checkAuth();
        if ($user) {

            $this->view->cate = $m->getCategory();

            if ($_GET['caid'] != "") {
                $caid = intval($_GET['caid']);
            }

            if ($caid > 0 && $this->view->cate['list'][$caid]) {
                $this->view->caid = $caid;
            } else {
                $this->view->caid = $this->view->cate['caid'];
            }  

            $page = 1;

            if($_GET['page']!="")
            {
                $page = intval($_GET['page']);
                if($page<=0)
                {
                    $page = 1;
                }
            }

            $para['caid'] = $this->view->caid;

            $this->view->width = 100/ count($this->view->cate['list']);

            $data = $m->getList($para,$page);

            //获取页码
            if ($data['maxpage'] > 1) {
                $data['spage'] = $m->fun->spage($data['page'], $data['maxpage']);
            }

            // print_r($data);

            $this->view->data = $data;

            $this->view->user = $user;
            $this->display();
        }

    }
}
